﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections;
using Seta;
using CommomFunctions;
using System.Windows.Media.Animation;

namespace Listas
{
    /// <summary>
    /// Interaction logic for Lists.xaml
    /// </summary>
    public partial class Lists : Window
    {
        /// <summary>
        /// Variable that contains the information about the controls and their operations.
        /// </summary>
        private ControlVariables ctrls = new ControlVariables();

        /// <summary>
        /// Constructor that executes the default initialization and then creates the other necessary controls 
        /// </summary>
        public Lists()
        {
            InitializeComponent();

            createList();
        }

        /// <summary>
        /// Creates the Binary Search Tree. 
        /// The array "btns" contains all the buttons in the project. It will be used to control
        /// which button is enabled or disabled according to the operation that is being executed.
        /// </summary>
        void createList()
        {
            Button[] btn = { btnCreate, btnDestroy, btnInsertAt, btnInsertFirst, btnInsertLast, btnRemoveAt, btnRemoveFirst, btnRemoveLast };
            ctrls.btnsToEnableDisable(btn);
            ctrls.addOtherControls(Gridi, ctrls);
        }

        private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            ctrls.gridSizeChanged(ctrls);
        }
                
        #region Buttons click events controls
        void btnDestroi_Click(object sender, RoutedEventArgs e)
        {
            ctrls.buttonClicked(ButtonClicked.Destroy, ctrls);
        }

        void btnCria_Click(object sender, RoutedEventArgs e)
        {
            ctrls.buttonClicked(ButtonClicked.Create, ctrls);            
        }
                
        private void btnInsertFirst_Click(object sender, RoutedEventArgs e)
        {
            ctrls.buttonClicked(ButtonClicked.InsertFirst, ctrls);
        }

        void btnInsertLast_Click(object sender, RoutedEventArgs e)
        {
            ctrls.buttonClicked(ButtonClicked.InsertLast, ctrls);
        }

        void btnInsertAt_Click(object sender, RoutedEventArgs e)
        {
            ctrls.buttonClicked(ButtonClicked.InsertAt, ctrls);          
        }

        void btnRemoveFirst_Click(object sender, RoutedEventArgs e)
        {
            ctrls.buttonClicked(ButtonClicked.RemoveFirst, ctrls);            
        }

        void btnRemoveLast_Click(object sender, RoutedEventArgs e)
        {
            ctrls.buttonClicked(ButtonClicked.RemoveLast, ctrls);
        }

        void btnRemoveAt_Click(object sender, RoutedEventArgs e)
        {
            ctrls.buttonClicked(ButtonClicked.RemoveAt, ctrls);
        }
        #endregion
        
        #region Menu click events controls
        private void about_Click(object sender, RoutedEventArgs e)
        {
             Ajuda.openAbout();
        }

        private void help_Click(object sender, RoutedEventArgs e)
        {
            Ajuda.openHelp();
        }

        private void tutorial_Click(object sender, RoutedEventArgs e)
        {
            Ajuda.openTutorial("Lista.wmv");
        }
        #endregion
    }
}